#pragma once
#include<iostream>
#include<vector>
#include<functional>
using namespace std;
namespace bit

{
    template <class T>
    struct less
    {
    public:
        bool  operator()(const T& x, const T& y)
        {
            return x < y;
        
        }



    };
    template <class T>
    struct greater
    {
    public:
        bool  operator()(const T& x, const T& y)
        {
            return x > y;

        }



    };
   
template <class T, class Container = vector<T>, class Compare = less<T> >

    class priority_queue

    {

    public:

        priority_queue()=default;

        template <class InputIterator>
        priority_queue(InputIterator first, InputIterator last)
        {
        
            while (first != last)
            {
                push(*first);
                first++;
            }
        
        
        
        }
        

        void adjust_up(int child)
        {
            int parent = (child - 1) / 2;
            while (child > 0)
            {
                if (comp(c[child],c[parent]))
                {
                    swap(c[child],c[parent]);
                    child = parent;
                    parent = (child - 1) / 2;
                }
                else
                {
                    break;
                }
            }
        
        
        
        
        
        }
        void adjust_down(int parent)
        {
            int child = parent * 2 + 1;
            while (child<c.size())
            {

                if (child + 1 < c.size() && comp(c[child + 1], c[child]))
                {
                    child = child + 1;

                }
                if (comp(c[child],c[parent]))
                {
                    swap(c[parent],c[child]);
                    parent = child;
                    child = parent * 2 + 1;



                }
                else
                {
                    break;
                }






            }
        
        
        
        
        }


        bool empty() const
        {
            return c.empty();
        
        
        
        }

        size_t size() const
        {
            return c.size();
        
        }

        const T& top() const
        {
        
            return c[0];
        
        }

        void push(const T& x)
        {    
            c.push_back(x);
            adjust_up(c.size() - 1);

        }

        void pop()
        {  
            swap(c[0], c[c.size() - 1]);
            c.pop_back();
            adjust_down(0);
        
        }

    private:

        Container c;
       Compare comp;

    };
    class Date
    {
    public:
      
        Date(int year = 1900, int month = 1, int day = 1)
            : _year(year)
            , _month(month)
            , _day(day)
        {}
        bool operator<(const Date& d)const
        {
            return (_year < d._year) ||
                (_year == d._year && _month < d._month) ||
                (_year == d._year && _month == d._month && _day < d._day);
        }
        bool operator>(const Date& d)const
        {
            return (_year > d._year) ||
                (_year == d._year && _month > d._month) ||
                (_year == d._year && _month == d._month && _day > d._day);
        }
        friend ostream& operator<<(ostream& _cout, const Date& d)
        {
            _cout << d._year << "-" << d._month << "-" << d._day;
            return _cout;
        }
    private:
        int _year;
        int _month;
        int _day;
    };
    class  Dateless
    {
    public:

        bool operator()(const Date* x, const Date* y)
        {

            return *x < *y;
        }

    };
    class  Dategreater
    {
    public:

        bool operator()(const Date* x, const Date* y)
        {

            return *x > *y;
        }

    };

  

        void test()
    {
        priority_queue<Date*, vector<Date*>, greater<Date*>> st;
        st.push(new Date(2018, 10, 29));
        st.push(new Date(2018, 10, 30));
        st.push(new Date(2018, 10, 28));
        while (!st.empty())
        {

            cout << *(st.top()) << endl;
            st.pop();
        }
       
       
     
    }

};





